//+--------------------------------------------------------------------------------
//| Copyright (c) 2012 - 2013 ### an.vuongngocduy
//| This file is a part of Compact Game Engine (CGE)
//+--------------------------------------------------------------------------------
#ifndef __CGE_IMAGETRANSCODERBMP_H__
#define __CGE_IMAGETRANSCODERBMP_H__

#include "cgeImageTranscoder.h"

namespace cge
{
	namespace gfx
	{
		//! Support reading and writing image from Bitmap file / buffer
		class ImageTranscoderBMP : public ImageTranscoder
		{
		public:
			//! Windows Bitmap format. File header
			PACKED_STRUCT_DEF struct FileHeaderBMP
			{
				u16 Magick;
				u32 FileSize;
				u32 Reserved;
				u32 DataOffset;
			}
			PACKED_STRUCT_END;
	
			
			//! Windows Bitmap format. Core header
			PACKED_STRUCT_DEF struct CoreHeaderBMP
			{
				u32 HeaderSize;
				s32 Width;
				s32 Height;
				u16 Planes;
				u16 BitsPerPixel;
				u32 Compression;
				u32 ImageSize;
				s32 PxPerMeterX;
				s32 PxPerMeterY;
				u32 ClrUsed;
				u32 ClrImportant;
				u32 RedMask;
				u32 GreenMask;
				u32 BlueMask;
				u32 AlphaMask;
			}
			PACKED_STRUCT_END;


		public:
			//! Load image from stream that contains Bitmap data
			virtual s8 LoadImage(Stream& inStream, Image& image) const;


			//! Write image to stream using Bitmap format 
			virtual s8 SaveImage(Stream& outStream, const Image& image) const;
		};
	}
}

#endif//__CGE_IMAGETRANSCODERBMP_H__